package com.edu.controller.front.complex;

import com.edu.entity.Food;
import com.edu.service.food.FoodService;
import com.edu.service.food.FoodServiceImpl;
import com.edu.utils.ParamFormat;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author ZCN
 * @version 1.0
 * @date 2021/11/22 14:37
 */
@WebServlet("/front/complexhots")
public class HotsComplexServlet extends HttpServlet {
    private FoodService foodService = new FoodServiceImpl();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            // 参数
            ParamFormat.format(req, resp);
            // 拿数据
            List<Food> hotsFoodsCom = foodService.hotsFoodsCom();
            // 传数据
            req.setAttribute("hotsFoodsCom",hotsFoodsCom);
            req.getRequestDispatcher("/front/hotsComplex.jsp").forward(req,resp);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
